from enum import Enum


class ResponseStatus(Enum):
    """
    响应状态枚举，包含状态码和消息
    """
    # 成功
    SUCCESS = (200, "操作成功")
    
    # 客户端错误
    BAD_REQUEST = (400, "请求参数错误")
    UNAUTHORIZED = (401, "未授权访问")
    FORBIDDEN = (403, "禁止访问")
    NOT_FOUND = (404, "资源不存在")
    METHOD_NOT_ALLOWED = (405, "请求方法不允许")
    VALIDATION_ERROR = (422, "数据验证失败")
    
    # 业务错误
    BUSINESS_ERROR = (460, "业务逻辑错误")
    ADMIN_CANNOT_QUIT_PROJECT = (460008, "管理者不能退出项目")
    CANNOT_QUIT_DEFAULT_PROJECT = (460009, "不能退出默认公共库项目")
    
    # 服务器错误
    INTERNAL_ERROR = (500, "服务器内部错误")
    DATABASE_ERROR = (501, "数据库操作失败")
    REDIS_ERROR = (502, "缓存操作失败")
    EXTERNAL_API_ERROR = (503, "外部API调用失败")
    
    def __init__(self, code: int, message: str):
        self.code = code
        self.message = message
    
    @property
    def status_code(self) -> int:
        """获取状态码"""
        return self.code
    
    @property
    def status_message(self) -> str:
        """获取状态消息"""
        return self.message